﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
// If you have enabled NRTs for your project, then un-comment the following line:
// #nullable disable

namespace IVBlog.Models
{
    public partial class IVBlogContext : DbContext
    {
        public IVBlogContext()
        {
        }

        public IVBlogContext(DbContextOptions<IVBlogContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Admin> Admin { get; set; }
        public virtual DbSet<Article> Article { get; set; }
        public virtual DbSet<Category> Category { get; set; }
        public virtual DbSet<Dremark> Dremark { get; set; }
        public virtual DbSet<Dynamic> Dynamic { get; set; }
        public virtual DbSet<Img> Img { get; set; }
        public virtual DbSet<Info> Info { get; set; }
        public virtual DbSet<Remark> Remark { get; set; }
        public virtual DbSet<Reply> Reply { get; set; }
        public virtual DbSet<Tag> Tag { get; set; }
        public virtual DbSet<Theme> Theme { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
//#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
//                optionsBuilder.UseSqlServer("Server=.;Database=IVBlogDB;Uid=sa;Pwd=123456;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Admin>(entity =>
            {
                entity.Property(e => e.AdminId).HasColumnName("AdminID");

                entity.Property(e => e.Aaccount).HasMaxLength(50);

                entity.Property(e => e.Apassword).HasMaxLength(50);
            });

            modelBuilder.Entity<Article>(entity =>
            {
                entity.Property(e => e.ArticleId).HasColumnName("ArticleID");

                entity.Property(e => e.Acontent).HasColumnName("AContent");

                entity.Property(e => e.Aname)
                    .HasColumnName("AName")
                    .HasMaxLength(100);

                entity.Property(e => e.AreTime)
                    .HasColumnName("AReTime")
                    .HasColumnType("datetime");

                entity.Property(e => e.Astate).HasColumnName("AState");

                entity.Property(e => e.Asynopsis)
                    .HasColumnName("ASynopsis")
                    .HasMaxLength(100);

                entity.Property(e => e.Atime)
                    .HasColumnName("ATime")
                    .HasColumnType("datetime");

                entity.Property(e => e.Author).HasMaxLength(50);

                entity.Property(e => e.CategoryId).HasColumnName("CategoryID");

                entity.Property(e => e.ImgId).HasColumnName("ImgID");

                entity.Property(e => e.TagId1)
                    .HasColumnName("TagID1")
                    .HasMaxLength(50);

                entity.HasOne(d => d.Category)
                    .WithMany(p => p.Article)
                    .HasForeignKey(d => d.CategoryId)
                    .HasConstraintName("FK_Article_Category");
            });

            modelBuilder.Entity<Category>(entity =>
            {
                entity.Property(e => e.CategoryId).HasColumnName("CategoryID");

                entity.Property(e => e.Cname)
                    .HasColumnName("CName")
                    .HasMaxLength(50);

                entity.Property(e => e.Cnums).HasColumnName("CNums");
            });

            modelBuilder.Entity<Dremark>(entity =>
            {
                entity.ToTable("DRemark");

                entity.Property(e => e.DremarkId).HasColumnName("DRemarkID");

                entity.Property(e => e.Drcontent).HasColumnName("DRContent");

                entity.Property(e => e.Dremail)
                    .HasColumnName("DREmail")
                    .HasMaxLength(50);

                entity.Property(e => e.DrnickName)
                    .HasColumnName("DRNickName")
                    .HasMaxLength(50);

                entity.Property(e => e.Drstate).HasColumnName("DRState");

                entity.Property(e => e.Drtime)
                    .HasColumnName("DRTime")
                    .HasColumnType("datetime");

                entity.Property(e => e.Drweb)
                    .HasColumnName("DRWeb")
                    .HasMaxLength(100);
            });

            modelBuilder.Entity<Dynamic>(entity =>
            {
                entity.Property(e => e.DynamicId).HasColumnName("DynamicID");

                entity.Property(e => e.Dcontent).HasColumnName("DContent");

                entity.Property(e => e.Dstate).HasColumnName("DState");

                entity.Property(e => e.Dtime)
                    .HasColumnName("DTime")
                    .HasColumnType("datetime");
            });

            modelBuilder.Entity<Img>(entity =>
            {
                entity.Property(e => e.ImgId).HasColumnName("ImgID");

                entity.Property(e => e.ImgSrc).HasMaxLength(50);
            });

            modelBuilder.Entity<Info>(entity =>
            {
                entity.Property(e => e.InfoId).HasColumnName("InfoID");

                entity.Property(e => e.Email).HasMaxLength(50);

                entity.Property(e => e.InfoName).HasMaxLength(50);

                entity.Property(e => e.Qq)
                    .HasColumnName("QQ")
                    .HasMaxLength(50);

                entity.Property(e => e.Qqgroup)
                    .HasColumnName("QQGroup")
                    .HasMaxLength(50);
            });

            modelBuilder.Entity<Remark>(entity =>
            {
                entity.Property(e => e.RemarkId).HasColumnName("RemarkID");

                entity.Property(e => e.ArticleId).HasColumnName("ArticleID");

                entity.Property(e => e.Rcontent).HasColumnName("RContent");

                entity.Property(e => e.Remail)
                    .HasColumnName("REmail")
                    .HasMaxLength(50);

                entity.Property(e => e.RnickName)
                    .HasColumnName("RNickName")
                    .HasMaxLength(80);

                entity.Property(e => e.Rstate).HasColumnName("RState");

                entity.Property(e => e.Rtime)
                    .HasColumnName("RTime")
                    .HasColumnType("datetime");

                entity.Property(e => e.Rweb)
                    .HasColumnName("RWeb")
                    .HasMaxLength(100);

                entity.HasOne(d => d.Article)
                    .WithMany(p => p.Remark)
                    .HasForeignKey(d => d.ArticleId)
                    .HasConstraintName("FK_Remark_Article");
            });

            modelBuilder.Entity<Reply>(entity =>
            {
                entity.Property(e => e.ReplyId).HasColumnName("ReplyID");

                entity.Property(e => e.RemarkId).HasColumnName("RemarkID");

                entity.Property(e => e.ReplyEmail).HasMaxLength(50);

                entity.Property(e => e.ReplyNickName).HasMaxLength(80);

                entity.Property(e => e.ReplyTime).HasColumnType("datetime");

                entity.Property(e => e.ReplyWeb).HasMaxLength(100);

                entity.HasOne(d => d.Remark)
                    .WithMany(p => p.Reply)
                    .HasForeignKey(d => d.RemarkId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK_Reply_Remark");
            });

            modelBuilder.Entity<Tag>(entity =>
            {
                entity.Property(e => e.TagId).HasColumnName("TagID");

                entity.Property(e => e.TagName).HasMaxLength(50);
            });

            modelBuilder.Entity<Theme>(entity =>
            {
                entity.Property(e => e.ThemeId)
                    .HasColumnName("ThemeID")
                    .ValueGeneratedNever();

                entity.Property(e => e.ThemeColor).HasMaxLength(50);

                entity.Property(e => e.ThemeFont).HasMaxLength(50);
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
